﻿

@model MultiTenant.Models.RetailerViewModel
@using System.Web.Optimization
@using MultiTenant.Helpers
@using MultiTenant.Common.Types
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@Styles.Render(@Url.StyleBundle(Model.CurrentTenant, @ContentTypes.RetailerStylesheet, "~/Content/retailer.bundle.css"))

<div>
    <h2>This is the CORE retailer.</h2>
</div>

@if (Model.CurrentTenant.Id == TenantIds.AppleId)
{
    <div>
        @Html.ActionLink("Apple Retailer content", "RetailerInfo", "Retailer", new {Area = "Apple"}, new {})
    </div>

    <br/>
}

@if (AccessHelper.HasAccess(Model.CurrentTenant, AccessTypes.Premium))
{
    <div>
        @Html.ActionLink("Premium Retailer content", "RetailerInfo", "Retailer", new {Area = "Premium"}, new {})
    </div>

    <br/>
}

<div id="retailerGrid"></div>

<section class="panel retailerPanel">
    <div class="panelHeader"><strong>Retailer</strong></div>
    <div>
        <span class="retailerLabel">Id:</span>
        <span>@Html.TextBoxFor(model => model.Id)</span>
    </div>
    <div>
        <span class="retailerLabel">Name:</span>
        <span>@Html.TextBoxFor(model => model.Name)</span>
    </div>
    <div>
        <span class="retailerLabel">Number:</span>
        <span>@Html.TextBoxFor(model => model.Number)</span>
    </div>
</section>


 @if (AccessHelper.HasAccess(Model.CurrentTenant, AccessTypes.Premium))
 {
     @Html.Partial("../../Areas/Premium/Views/Retailer/RetailerSalesPartial", Model)
 }

 @if (Model.CurrentTenant.Id == TenantIds.AppleId)
 {
     @Html.Partial("../../Areas/Apple/Views/Retailer/RetailerAppleProductsPartial", Model)
 }

@Html.PartialHelper(Model.CurrentTenant, @ContentTypes.RetailerPartial, Model, "General")

<script type="text/javascript">
    $("#retailerGrid").kendoGrid({
        autoBind: true,
        change: function () {
        },
        filterable: false,
        groupable: false,
        height: "300px",
        pageable: true,
        resizeable: true,
        selectable: "single, row",
        sortable: {
            mode: "single",
            allowUnsort: false
        },
        dataSource: {
            pageSize: 30,
            type: "json",
            transport: {
                read: function (options) {
                    $.ajax({
                        url: "@Url.Action("GetRetailers", "api/RetailerApi", new { Area = ""})",
                        success: function (result) {
                            options.success(result);
                        },
                        type: "GET"
                    });
                }
            },
            schema: {
                model: {
                    id: "Id",
                    fields: {
                        Name: { type: "string" },
                        Number: { type: "number" },
                    }
                }
            }
        },
        columns: [
            {
                field: "Id",
                title: "Retailer Id",
                width: "70px"
            },
            {
                field: "Name",
                title: "Name",
                width: "180px"
            }, {
                field: "Number",
                title: "Number",
                width: "90px"
            }]
    });
</script>
